Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

167
Visualizações
Making "View" fill upp entire screen in React Native

I am working on a React-native project and stumbled upon issues when setting width and height using percentage values to a View. I have tried to set width: 100% and height: 100% but this does not work.

function CalendarPage() {
  return (
  <MainWrapper>
    <SafeAreaView style={styles.container}>
       <ScrollView>
        <StyleContentWrapper>
          <Paragraph> Hello World! </Paragraph>
        </StyleContentWrapper>
      </ScrollView>
    </SafeAreaView>
  </MainWrapper>
  );
}
const MainWrapper = styled.View`
  flex: 1; 
  justify-content: center; 
  align-items: center; 
  background-color: lightgray; 
  color: white;
`
const StyleContentWrapper = styled.View`
  height: 100%;     // this does not work
  width: 100%;      // this does not work
  background-color: red;
  padding-top: 40px;
  padding-horizontal: 20px;

`

A quick explaination for the components: MainWrapper covers the entire screen and is the base layer. The reason why it nests SafeAreaView is because this allows me to set a background color on the "safe area".

I have also nested another view called StyleContentWrapperinside a ScrollView, because I want everything inside to be scrollable.

This is the results

StyledContentWrapper or The red box does not cover the entire screen, despite having the styles of width: 100% and height: 100%. Why is this? Setting fixed width and height does work, but this is not the approach I want, because different devices has different widths and heights, and I want it to work for multiple screens with different widths and heights, hence the use of perecentage.

How can I solve this?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda